package per.com.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import per.com.bean.BaseBean;
import per.com.bean.SportConfig;
import per.com.service.impl.SportConfigService;

/**
 * Created by wubihang on 2018/9/21.
 */
@Controller
@RequestMapping("/sport")
public class MyConfigController {

    /*
    建表

    1.创建Dao  在Dao的接口上添加注解
    2.创建Mapper 在mapper里引用Dao
        在mybatis的配置文件中，注册mapper
            <mappers>
                    <mapper resource="per/com/mapper/UserMapper.xml"/>
                     <mapper resource="per/com/mapper/DeviceMapper.xml"/>
                     <mapper resource="per/com/mapper/DeviceCategoryMapper.xml"/>
                    <mapper resource="per/com/mapper/SportConfigMapper.xml"/>
             </mappers>
     3.在Controller定义Dao对象


     */





    @Autowired
    @Qualifier("SportConfigServiceId")
    private SportConfigService sportConfigService;

    @RequestMapping(value = "/getAll",method = RequestMethod.POST)
    @ResponseBody
    public BaseBean getAll(){
        return new BaseBean(0,"success",sportConfigService.getAll());
    }


    @RequestMapping(value = "/addConfig",method = RequestMethod.POST)
    @ResponseBody
    public BaseBean addConfig(SportConfig sportConfig){
        sportConfigService.insertSelective(sportConfig);
        return new BaseBean(0,"success",sportConfig);
    }




}
